<?php

class Application_Model_DbTable_Activity extends Zend_Db_Table_Abstract {

    protected $_name = 'bot_activity';
    
    public function getAllActivity(){
    	$rows = $this->fetchAll();
    	return $rows;
    }
	
	public function getAllActivityFromID($id){
        $rows = $this->fetchAll("markread = 0 and (botId = ".$id." or botIdWith = ".$id.")");
        return $rows;
	}
			
	public function createActivity($botId,$botIdWith,$msg){
		$row = $this->createRow();
		$row->botId = $botId;
		$row->botIdWith = $botIdWith;
		$row->information = $msg;
		$row->markread = 0;
		$row->save();
		return $row;
	}

	public function markActivity($botId){
		$db = $this->getAdapter();
		$set = array('markread'=>1);
		$where = $db->quoteInto('botId', $botId);
		$db->update( $this->_name, $set, $where );		
		return $rows_affected;
	}
}
